<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  Function.prototype.addMethod = function(name, fn){
    this[name] = fn;
    // 链式调用addMethod方法
    return this;
  }
  var methods = new Function();
  methods.addMethod('checkName', function(){
    // 验证姓名
    console.log('name checked')
    return this;
  }).addMethod('checkEmail', function(){
    // 验证邮箱
    console.log('email checked');
    return this;
  }).addMethod('checkPassword', function(){
    // 验证密码
    console.log('password checked')
    return this;
  })

  methods.checkName().checkEmail().checkPassword();
</script>
</body>
</html>